﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GameNesSL.Controls
{
    public partial class fontbutton : UserControl
    {
        public new static DependencyProperty IsEnabledProperty = DependencyProperty.Register("IsEnabled",typeof(bool), typeof(fontbutton), new PropertyMetadata(true, EnabledChanged));

        private static void EnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((fontbutton) d).txtBlock.Foreground = (bool)e.NewValue?new SolidColorBrush(Colors.White):new SolidColorBrush(Colors.LightGray);
        }

        public static DependencyProperty TextProperty = DependencyProperty.Register("Text",typeof(string), typeof(fontbutton), new PropertyMetadata("",TextChanged));

        private static void TextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((fontbutton)d).txtBlock.Text = string.Format(" {0} ", (string)e.NewValue); 
        }

        public string Text
        {
            get
            {
                return (string) GetValue(TextProperty);
            }
            set
            {
                SetValue(TextProperty, value);
            }
        }



        public new bool IsEnabled
        {
            get
            {
                return (bool) GetValue(IsEnabledProperty);
            }
            set
            {
                SetValue(IsEnabledProperty, value);
            }
        }



        public fontbutton()
        {
            InitializeComponent();
        }

        private void txtBlock_MouseEnter(object sender, MouseEventArgs e)
        {
            txtBlock.Text = string.Format("-{0}-", Text);
            txtBlock.Foreground = new SolidColorBrush(Colors.Red);
            txtBlock.TextDecorations = null;
        }

        private void txtBlock_MouseLeave(object sender, MouseEventArgs e)
        {
            txtBlock.Text = string.Format(" {0} ", Text);
            txtBlock.Foreground = new SolidColorBrush(Colors.White);
            txtBlock.TextDecorations = TextDecorations.Underline;
        }
    }
}
